<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>

<body>
    <div id="list">
        <div class="user-index-t" style="padding-top:3rem;">
            <div class="user-index-t-l">
                余额(元)
                <p>0.00</p>
                <div class="user-index-t-cz">充值</div>
            </div>
            <div class="user-index-t-m">
                <img src="{{=it.avatar}}" tapmode>
                <p>游客</p>
                [会员]
            </div>
            <div class="user-index-t-l">
                积分
                <p>0</p>
            </div>
            <div class="user-index-t-setup" tapmode>
                <i class="fa fa-gear"></i>
            </div>
        </div>
    </div>
    <div class="aui-content">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-calendar"></i> 我的订单
                    </div>
                    <div class="aui-list-item-right" tapmode onclick="order('all')">
                        查看更多订单
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <ul class="user-order aui-margin-b-15">
        <li tapmode onclick="order('waitPay')">
            <i class="fa fa-calendar-check-o"></i>
            <p>待付款</p>
        </li>
        <li tapmode onclick="order('waitSend')">
            <i class="fa fa-truck"></i>
            <p>待发货</p>
        </li>
        <li tapmode onclick="order('waitReceive')">
            <i class="fa fa-archive"></i>
            <p>待收货</p>
        </li>
        <li tapmode onclick="order('waitComment')">
            <i class="fa fa-archive"></i>
            <p>待评价</p>
        </li>
<!--         <li tapmode>
            <i class="fa fa-history"></i>
            <p>退换货</p>
        </li> -->
    </ul>

    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item" tapmode onclick="coupon()">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-credit-card-alt"></i> 领取优惠券
                    </div>
                </div>
            </li>
            <li class="aui-list-item" tapmode onclick="usercoupon()">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-credit-card"></i> 我的优惠券
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item" onclick="integralRank();">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-bar-chart-o"></i> 积分排行
                    </div>
                </div>
            </li>
            <li class="aui-list-item" onclick="payRank();">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-line-chart"></i> 消费排行
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-list-in">
<!--             <li class="aui-list-item" tapmode onclick="cart()">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-shopping-cart"></i> 我的购物车
                    </div>
                </div>
            </li> -->
            <li class="aui-list-item" tapmode onclick="address()">
                <div class="aui-list-item-inner aui-list-item-arrow">
                    <div class="aui-list-item-title">
                        <i class="fa fa-map-marker"></i> 收货地址管理
                    </div>
                </div>
            </li>
        </ul>
    </div>



    <!-- <div class="foot-t"></div>
<div class="foot">
    <ul>
        <li tapmode onclick="index()">
            <img src="./images/foot-1.png">
            <p>首页</p>
        </li>
        <li tapmode onclick="goodslist()">
            <img src="./images/foot-2.png">
            <p>商城</p>
        </li>
        <li class="foot-m" tapmode onclick="cart()">
            <img src="./images/foot-5.png">
        </li>
        <li tapmode onclick="distribution()">
            <img src="./images/foot-3.png">
            <p>分销</p>
        </li>
        <li>
            <img src="./images/foot-4.png">
            <p>我的</p>
        </li>
    </ul>
</div> -->

</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/template" id="template">
    <div class="user-index-t" style="padding-top:3rem;">
        <div class="user-index-t-l">
            余额(元)
            <p>{{=it.money}}</p>
            <div class="user-index-t-cz">充值</div>
        </div>
        <div class="user-index-t-m">
            <img src="{{=it.avatar}}" tapmode onclick="usersetup()">
            <p>{{=it.nickname}}</p>
            [{{=it.role_name}}]
        </div>
        <div class="user-index-t-l">
            积分
            <p>{{=it.point}}</p>
        </div>
        <div class="user-index-t-setup" tapmode onclick="usersetup()">
            <i class="fa fa-gear"></i>
        </div>
    </div>
</script>
<script type="text/javascript">

    apiready = function() {
        reloadListener();
        isLogin();
    }

    function loadData(){
        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        api.ajax({
            url: webAddress + '/a/member/Member',
            method: 'post',
            data: {
                values: {
                },
            },
            headers: {
                TOKEN: token,
                authuid: userid,
                authtoken: authtoken,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );
                if (ret.result) {
                    templateFun(ret.result);
                }

            } else {
                // alert( JSON.stringify( err ) );
                api.toast({
                    msg: err.body.message,
                    duration: 2000,
                    location: 'bottom'
                });
                return false;
            }
        });
    }

    // 模板赋值函数
    function templateFun(data){
        if (data) {
          var template = $api.byId('template');
          var dotFn = doT.template(template.innerHTML);
          var html = dotFn(data);
          var list = $api.byId('list');
          $api.html(list, html);
      }
  }

    // 判断是否登录
    function isLogin(){
        var userid = $api.getStorage('userid');
        if(!userid){
            api.confirm({
                title: '提示',
                msg: '请登录!',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    if (ret.buttonIndex == 1) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });
                        return false;
                    }else{
                        return false;
                    }
                }else{
                 // alert( JSON.stringify( err ) );
                 return false;
             }
         });
        }else{
            loadData();
        }

    }

    // 监听事件 (页面刷新)
    function reloadListener(){
        api.addEventListener({
            name: 'reload',
        }, function(ret, err){
           loadData();
       });
    }

    function openClub() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'club_win',
            url: './html/club_win.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    function index() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'index',
            url: './index.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    function goodslist() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'goodslist',
            url: './goods_list.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    };

    function cart() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'cart',
            url: './cart.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    function distribution() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'distribution',
            url: './distribution.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    function usersetup() {

        // 判断是否登录
        var userid = $api.getStorage('userid');
        if(!userid){
            api.confirm({
                title: '提示',
                msg: '请登录!',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    if (ret.buttonIndex == 1) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });
                        return false;
                    }else{
                        return false;
                    }
                }else{
                   // alert( JSON.stringify( err ) );
                   return false;
               }
           });
        }else{


            var delay = 0;
            if (api.systemType != 'ios') {
                delay = 300;
            }
            api.openWin({
                name: 'usersetup',
                url: './user_setup.html',
                bounces: false,
                delay: delay,
                slidBackEnabled: true,
                vScrollBarEnabled: false,
                progress: {
                    type: "page"
                }
            });
        }
    }

    // 订单页
    function order(type) {

        // 判断是否登录
        var userid = $api.getStorage('userid');
        if(!userid){
            api.confirm({
                title: '提示',
                msg: '请登录!',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    if (ret.buttonIndex == 1) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });
                        return false;
                    }else{
                        return false;
                    }
                }else{
                   // alert( JSON.stringify( err ) );
                   return false;
               }
           });
        }else{

            var delay = 0;
            if (api.systemType != 'ios') {
                delay = 300;
            }
            api.openWin({
                name: 'order',
                url: './order.html',
                bounces: false,
                delay: delay,
                slidBackEnabled: true,
                vScrollBarEnabled: false,
                progress: {
                    type: "page"
                },
                pageParam: {
                    type: type,
                },
            });
        }
    }

    function address() {
        var userid = $api.getStorage('userid');
        if(!userid){
            api.confirm({
                title: '提示',
                msg: '请登录!',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    if (ret.buttonIndex == 1) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });
                        return false;
                    }else{
                        return false;
                    }
                }else{
                 // alert( JSON.stringify( err ) );
                 return false;
             }
         });
        }else{


            var delay = 0;
            if (api.systemType != 'ios') {
                delay = 300;
            }
            api.openWin({
                name: 'address',
                url: './address.html',
                bounces: false,
                delay: delay,
                slidBackEnabled: true,
                vScrollBarEnabled: false,
                progress: {
                    type: "page"
                }
            });
        }
    }

    // 领取优惠券页
    function coupon() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'coupon',
            url: './coupon.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    // 我的优惠券页
    function usercoupon() {
        var userid = $api.getStorage('userid');
        if(!userid){
            api.confirm({
                title: '提示',
                msg: '请登录!',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    if (ret.buttonIndex == 1) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });
                        return false;
                    }else{
                        return false;
                    }
                }else{
                    return false;
                }
            });
        }else{

            var delay = 0;
            if (api.systemType != 'ios') {
                delay = 300;
            }
            api.openWin({
                name: 'usercoupon',
                url: './user_coupon.html',
                bounces: false,
                delay: delay,
                slidBackEnabled: true,
                vScrollBarEnabled: false,
                progress: {
                    type: "page"
                }
            });
        }
    }

    function closeWin() {
        api.closeWin({});
    }

    // 注册页
    function register(){
        api.openWin({
            name: 'register',
            url: './goods_order.html',
            pageParam: {
                name: 'test'
            }
        });
    }

    // // 登录页
    // function login(){
    //     api.openWin({
    //         name: 'login',
    //         url: './login.html',
    //         pageParam: {
    //             name: 'test'
    //         }
    //     });
    // }

    // 积分排行
    function integralRank(){
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'integral-rank',
            url: './integral_rank.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }

    // 消费排行
    function payRank(){
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'consume-rank',
            url: './consume_rank.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }
</script>

</html>
